# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：get_stock_rank.py
#日期：2019-04-29
#备注：获取数据库中的
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
from pacong.stock.stock_config  import cursor


def get_stock_nos():
    sql = 'select stock_type,stock_no,stock_name from china_stock;'
    cursor.execute(sql)
    results = cursor.fetchall()
    stocks = []
    for stock in results:
        row = []
        stock_type = stock[0]
        stock_no = stock[1]
        stock_name = stock[2]
        if stock_type == '1':
            stock_no = 'SH' + stock_no
        else:
            stock_no = 'SZ' + stock_no
        row.append(stock_no)
        row.append(stock_name)
        stocks.append(row)
    return stocks

def get_stock_no():
    sql = 'select stock_type,stock_no,stock_name from china_stock;'
    cursor.execute(sql)
    results = cursor.fetchall()
    stocks = []
    for stock in results:
        row = []
        stock_type = stock[0]
        stock_no = stock[1]
        stock_name = stock[2]
        row.append(stock_type)
        row.append(stock_no)
        row.append(stock_name)
        stocks.append(row)
    return stocks

def get_stock_no_price():
    sql = 'select stock_no from china_stock where stock_no in (select stock_no from stock_tradeinfo_20230424 where price_new<10);'
    cursor.execute(sql)
    results = cursor.fetchall()
    stocks = []
    for stock in results:
        if '688' not in stock[0]:
            stocks.append(stock[0])
    return(stocks)


if __name__ == '__main__':
    get_stock_no_price()
    #get_stock_no()